package cn.smxy.user.util;

import cn.smxy.constant.RegexConstant;
import cn.smxy.pojo.College;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class NumberUtil {
    /**
     * 学号校验方法
     * 1.正则
     * 2.长度
     * @param college
     * @param studentNumber
     * @return
     */
    public static boolean check(College college,String studentNumber) {
        String numberRegular = college.getNumberRegular();
        if(numberRegular != null && !numberRegular.equals("")) {
            Pattern pattern = Pattern.compile(numberRegular);
            Matcher matcher = pattern.matcher(studentNumber);
            return matcher.matches();
        }
        Integer numberLength = college.getNumberLength();
        return studentNumber.length() == numberLength;
    }
}
